home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6593 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!samtech.demon.co.uk
  2. From: Richard Samuels <Richard@samtech.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Can anyone optimize this VERY simple piece of code?
  5. Date: Fri, 16 Feb 1996 11:43:30 +0000
  6. Organization: SAMtech PC Systems
  7. Message-ID: <19950700wnr@samtech.demon.co.uk>
  8. Reply-To: Richard@samtech.demon.co.uk
  9. X-NNTP-Posting-Host: samtech.demon.co.uk
  10. X-Newsreader: Newswin Alpha 0.9.1
  11. X-Mail2News-Path: disperse.demon.co.uk!post.demon.co.uk!samtech.demon.co.uk
  12.  
  13. Hi, has anybody got any clues as to how I could optimize this little section 
  14. of code?
  15. It is VERY simple but also VERY slow and I was just wondering if anybody has 
  16. any ideas for speeding it up...
  17.  
  18.  
  19. void vga_putbackground(int startx, int starty, unsigned char huge *image)
  20. {
  21.  //Variables:
  22.  int x,y;
  23.  unsigned int count;
  24.  long bgoffs;
  25.  
  26.  //Code:
  27.  //note: image[] is 2 screens in size (640x200) array...
  28.   //...need routine to take current section only
  29.   //...multiple calls can then create scrolling bground!
  30.  
  31.  //loop from beginning of screen buffer to end of screen buffer:
  32.  count=0;
  33.  for(y=starty;y<SCREENHEIGHT+starty;y++)
  34.   for(x=startx;x<SCREENWIDTH+startx;x++)
  35.   {
  36.    //vga mem offset is just one continuous line.
  37.    //bground offset is: 
  38.    bgoffs = (long) ((long)x+((long)y*640L));
  39.  
  40.    //copy bground mem to vga buffer:
  41.    vgamem[count]=image[bgoffs];
  42.    count++;
  43.   }
  44. }
  45.  
  46. If you could also e-mail me the reply it would be much appreciated.
  47. Thanks,
  48. Richard.
  49.